﻿using System.Configuration;
using System.Threading;
using MbUnit.Framework;
using Microsoft.VisualStudio.WebHost;

namespace DocumentaWeb.Tests.Acceptance
{
	[TestFixture(ApartmentState = ApartmentState.STA),FixtureCategory("Tests de Aceptación")]
	public abstract class BaseAcepptanceTestFixture
	{
		private Server webServer;
		private int port;
		private string webDir;

		[TestFixtureSetUp]
		public void SetUp()
		{
			port = int.Parse(ConfigurationManager.AppSettings["webPort"]);
			webDir = ConfigurationManager.AppSettings["webDirectory"];

			webServer=new Server(port,"/",webDir);
			webServer.Start();
		}

		[TestFixtureTearDown]
		public void TearDown()
		{
			webServer.Stop();
		}

		internal string BuildUrl(string path)
		{
			const string URL_FORMAT = "http://localhost:{0}/{1}";
			return string.Format(URL_FORMAT, port, path);
		}
	}
}
